package appita.general;



import org.json.JSONException;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Gallery;
import android.widget.TextView;
import appita.parser.Parser;
import appita.util.Effect;

public class ElencoParole extends Activity {
	private Gallery galleryView;
	private String [] nomiParole;
	private String [] fotoParole;
	private String [] audioParole;
	private Effect audio_parole;
	

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.elenco_parole);
		
		
		//Lettera.getInstance().setArrayCompleto(Parser.getInstance().createArrayJson(this, R.raw.parole));

		// Recupero il nome della lettera scelto e lo scrivo nella TextView
		Intent intent = getIntent();
		String pkg = getPackageName();
		String nomeLettera = intent.getStringExtra(pkg + ".lettera");
		TextView textview = (TextView) findViewById(R.id.nome_lettera);
		textview.setText(nomeLettera);
		// //////////////////////////////////////////////////////////////////

		galleryView = (Gallery) findViewById(R.id.galleryid);
		   
		try {
				
				 Parser.getInstance().parseParole(Lettera.getInstance().getArrayCompleto(), nomeLettera.substring(8));
				 nomiParole=Lettera.getInstance().getNomiParole();
				 fotoParole=Lettera.getInstance().getFotoParole();
				 audioParole=Lettera.getInstance().getAudioParole();
			
		} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		
		
		
	galleryView.setAdapter(new ImageAdapterIta(this,nomiParole,fotoParole,audioParole));
		
		

	}

}
